package com.zh.article;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * @description:
 * @author: zhangHang
 * @date: Created in 2020/5/24 10:37
 * @version: 1.0
 * @modified By:
 */
public class DrugSet {
    private ArrayList<Drug> drugs = new ArrayList<>();
    private String id;
    private String description;

    public DrugSet() {
    }

    public DrugSet(ArrayList<Drug> drugs, String id, String description) {
        this.drugs = drugs;
        this.id = id;
        this.description = description;
    }

    public Drug get(String id){
        Drug drug = null;
        for (Drug item:drugs
             ) {
            if(id.equals(item.getId())){
                drug = item;
                break;
            }
        }
        return drug;
    }

    public void remove(String id){
        Iterator<Drug> it = drugs.iterator();
        while (it.hasNext()){
            Drug value = it.next();
            if (value.equals(get(id))){
                it.remove();
            }
        }
    }

    public ArrayList<Drug> getDrugs() {
        return drugs;
    }

    public void setDrugs(ArrayList<Drug> drugs) {
        this.drugs = drugs;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }
}
